package com.tnsw.facebookautoliker.helper.command;

import java.util.ArrayList;

import android.content.Context;

import com.tnsw.coreutils.database.RecordBase;
import com.tnsw.facebookautoliker.database.DBManager;
import com.tnsw.facebookautoliker.helper.FacebookCommandObject;
import com.tnsw.facebookautoliker.helper.GeneralManager;

public class SQLiteSelect extends FacebookCommandObject {
	
	private GeneralManager gm ;
	private DBManager dbm;
	
	private String sql;
	private String[] values;

	public SQLiteSelect(Context context, String sql, String[] values) {
		super(context);
		
		super.tag = "SQLiteSelect";
		this.sql = sql;
		this.values = values;
		
		this.gm = GeneralManager.getInstance();
		this.dbm = DBManager.getInstance(context);
		
		this.setTag("sql", sql);
		if (values != null) {
			this.setTag("values", values);	
		}
		
	}
	
	@Override
	public void execute() {
		super.execute();
		
		ArrayList<Object> a = this.dbm.getRawRecords(this.sql, this.values, 0);
		if (a != null) {
			this.setTag("result", a);	
		}
		
		super.fbm.updateCommandStatus(this, 200, null);
		
	}
	
}
